//
//  Word.m
//  FolketsLexikon
//
//  Created by Ying Wang on 11/22/10.
//  Copyright 2010 Uppsala University. All rights reserved.
//

#import "Word.h"


@implementation Word
@synthesize wordText;
@synthesize wordClass;
@synthesize wordLanguage;
@synthesize wordTranslation;
@synthesize phoneticText;
@synthesize synonym;
@synthesize example;
@synthesize translation;
@synthesize idiom;
@synthesize explanation;
@synthesize content;


-(void) dealloc{
	[wordText release];
	[wordClass release];
	[wordLanguage release];
	[wordTranslation release];
	[phoneticText release];
	[synonym release];
	[example release];
	[translation release];
	[idiom release];
	[explanation release];  
	[content release];  
	[super dealloc];
}

- (NSString *)ToString{
	NSMutableString *formattedResult = [[NSMutableString alloc]initWithFormat:@"<body style=\"background:#D1EEEE\"><h4><font color='black' size=10><b>%@</b></font> <font size=1><b>%@</font>  %@  [%@]</b></font></h4><font color='##000099' size=5><b>%@</b></font>%@",
										wordText,wordLanguage,wordClass,phoneticText,wordTranslation,content];
	return formattedResult;
}

- (void)appendContent:(NSString*)str{
	if (str!=nil)
	content=[content stringByAppendingString:str];
}

- (void)appendContentWithLeadingSpace:(NSString*)str{
	content=[content stringByAppendingString:@"  "];
	if (str!=nil)
	content=[content stringByAppendingString:str];
}

- (void)appendContentWithEndingSpace:(NSString*)str{
	content=[content stringByAppendingString:str];
	if (str!=nil)
	content=[content stringByAppendingString:@"  "];

}

- (void)appendContentWithSpace:(NSString*)str{
	content=[content stringByAppendingString:@"  "];
	if (str!=nil)
	content=[content stringByAppendingString:str];
	content=[content stringByAppendingString:@"  "];
}

- (void)appendContentWithLeadingNewLine:(NSString*)str{
	content=[content stringByAppendingString:@"\n"];
	if (str!=nil)
	content=[content stringByAppendingString:str];
}

- (void)appendContentWithEndingNewLine:(NSString*)str{
	if (str!=nil)
	content=[content stringByAppendingString:str];
	content=[content stringByAppendingString:@"\n"];
}

- (void)appendContentWithNewLine:(NSString*)str{
	content=[content stringByAppendingString:@"\n"];
	if (str!=nil)
	content=[content stringByAppendingString:str];
	content=[content stringByAppendingString:@"\n"];
}

-(void)setWordClass:(NSString *)class{
	if ([class isEqualToString: @"nn"])
	{
		wordClass = @"substantiv";
		return;
	}
	else if ([class isEqualToString: @"vb"])
	{
		wordClass = @"verb";
		return;
	}
	else if ([class isEqualToString: @"jj"])
	{
		wordClass = @"adjektiv";
		return;
	}
	else if ([class isEqualToString: @"ab"])
	{
		wordClass = @"adverb";
		return;
	}
	else if ([class isEqualToString: @"kn"])
	{
		wordClass = @"konjunktion";
		return;
	}
	else if ([class isEqualToString: @"pp"])
	{
		wordClass = @"preposition";
		return;
	}
	else if ([class isEqualToString: @"in"])
	{
		wordClass = @"interjection";
		return;
	}
	else if ([class isEqualToString: @"pn"])
	{
		wordClass = @"pronomen";
		return;
	}
	else if ([class isEqualToString: @"abbrev"])
	{
		wordClass = @"förkortning";
		return;
	}
	wordClass = class;
}

@end













